﻿<Window x:Class="SettingsWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:vm="clr-namespace:DotNetNuke.Translator.ViewModel"
  xmlns:vw="clr-namespace:DotNetNuke.Translator.View"
    Title="SettingsWindow" Height="770" Width="800">

 <Window.Resources>
  <DataTemplate DataType="{x:Type vm:TranslatorSettingsViewModel}">
   <vw:TranslatorSettingsView HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
  </DataTemplate>

  <DataTemplate DataType="{x:Type vm:ProjectSettingsViewModel}">
   <vw:ProjectSettingsView HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
  </DataTemplate>

  <DataTemplate x:Key="SettingPanelsTemplate">
   <TabControl 
      IsSynchronizedWithCurrentItem="True" 
      ItemsSource="{Binding}"
      Margin="4"
      SelectedItem="{Binding Path=DataContext.SelectedPanel, Mode=TwoWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}"
      >
    <TabControl.ItemContainerStyle>
     <Style TargetType="TabItem">
      <Setter Property="Visibility" Value="Collapsed" />
     </Style>
    </TabControl.ItemContainerStyle>
    <TabControl.ItemTemplate>
     <DataTemplate>
      <TextBlock Text="{Binding DisplayName}" />
     </DataTemplate>
    </TabControl.ItemTemplate>
   </TabControl>
  </DataTemplate>

  <DataTemplate x:Key="SettingTabItemTemplate">
   <TextBlock Text="foo" />
  </DataTemplate>

 </Window.Resources>

 <Grid Background="#eee">
  <Grid.RowDefinitions>
   <RowDefinition Height="*" />
   <RowDefinition Height="Auto" />
  </Grid.RowDefinitions>
  <Grid Grid.Row="0">
   <Grid.ColumnDefinitions>
    <ColumnDefinition Width="Auto" />
    <ColumnDefinition Width="*" />
   </Grid.ColumnDefinitions>
   <StackPanel Grid.Column="0" Background="#fff" Margin="4" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
    <ItemsControl ItemsSource="{Binding SettingPanels}">
     <ItemsControl.ItemTemplate>
      <DataTemplate>
       <Button Margin="8" Padding="10,2"
               Command="{Binding Path=DataContext.SelectTabCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}"
               CommandParameter="{Binding}">
        <TextBlock Text="{Binding DisplayName}" />
       </Button>
      </DataTemplate>
     </ItemsControl.ItemTemplate>
    </ItemsControl>
   </StackPanel>
   <ContentControl Grid.Column="1" Background="#fff" Margin="4" 
    Content="{Binding Path=SettingPanels}"
    ContentTemplate="{StaticResource SettingPanelsTemplate}"
     />
  </Grid>
  <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.Row="1">
   <Button Content="Cancel" Margin="6" Command="{Binding CancelCommand}" CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}" Padding="10,2" />
   <Button Content="OK" Margin="6" Command="{Binding OkCommand}" CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}" Padding="10,2" />
  </StackPanel>
 </Grid>
</Window>
